using ConfigurationSettings;
using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using ServiceLocator;

namespace CustomControls.UserControls
{
    //TODO: 017 - Bind the ConfigSettings to a model. Then I can set the static ApplicationSettings class in the model variable then save the model.
    //Binding in WinForms
    //http://www.c-sharpcorner.com/Blogs/581/how-to-binding-a-property-to-a-label-control-in-a-windows-f.aspx
    public partial class UserControlFileColors : UserControlBase
    {
        ColorDialog _colorDialog1;
        FontDialog _fontDialog1;

        public UserControlFileColors()
        {
            InitializeComponent();
        }

        public override void Initialize()
        {
            _colorDialog1 = new ColorDialog
                {
                    AllowFullOpen = true,
                    AnyColor = true,
                    FullOpen = true,
                    SolidColorOnly = true,
                    ShowHelp = false
                };

            _fontDialog1 = new FontDialog
                {
                    ShowApply = false,
                    ShowEffects = true,
                    AllowScriptChange = true,
                    AllowVerticalFonts = false,
                    ScriptsOnly = false,
                    FixedPitchOnly = false,
                    AllowSimulations = true,
                    AllowVectorFonts = true,
                    FontMustExist = true,
                    ShowColor = true,
                    MaxSize = 10
                };

            //_configSettings = new ApplicationSettings();

            #region ** Item Colors **

            IApplicationSettings localSettings = Locator.Resolve<IApplicationSettings>();

            buttonPlainNameColor1.BackColor = localSettings.FileSettings.PlainSettings.NameColors.Color1;
            buttonPlainNameColor2.BackColor = localSettings.FileSettings.PlainSettings.NameColors.Color2;
            spinnerPlainNameAngle.Value = (decimal)localSettings.FileSettings.PlainSettings.NameColors.Direction;

            buttonPlainSizeColor1.BackColor = localSettings.FileSettings.PlainSettings.SizeColors.Color1;
            buttonPlainSizeColor2.BackColor = localSettings.FileSettings.PlainSettings.SizeColors.Color2;
            spinnerPlainSizeAngle.Value = (decimal)localSettings.FileSettings.PlainSettings.SizeColors.Direction;

            buttonPlainDateColor1.BackColor = localSettings.FileSettings.PlainSettings.DateColors.Color1;
            buttonPlainDateColor2.BackColor = localSettings.FileSettings.PlainSettings.DateColors.Color2;
            spinnerPlainDateAngle.Value = (decimal)localSettings.FileSettings.PlainSettings.DateColors.Direction;


            #endregion

            #region ** Item Selected Colors **

            //buttonSelectedNameColor1.BackColor = ApplicationSettings.SelectedFileNameColor1;
            //buttonSelectedNameColor2.BackColor = ApplicationSettings.SelectedFileNameColor2;
            //spinnerSelectedNameAngle.Value = (decimal)ApplicationSettings.SelectedFileNameColorDirection;

            //buttonSelectedSizeColor1.BackColor = ApplicationSettings.SelectedFileSizeColor1;
            //buttonSelectedSizeColor2.BackColor = ApplicationSettings.SelectedFileSizeColor2;
            //spinnerSelectedSizeAngle.Value = (decimal)ApplicationSettings.SelectedFileSizeColorDirection;

            //buttonSelectedDateColor1.BackColor = ApplicationSettings.SelectedFileDateColor1;
            //buttonSelectedDateColor2.BackColor = ApplicationSettings.SelectedFileDateColor2;
            //spinnerSelectedDateAngle.Value = (decimal)ApplicationSettings.SelectedFileDateColorDirection;

            buttonSelectedNameColor1.BackColor = localSettings.FileSettings.SelectedSettings.NameColors.Color1;
            buttonSelectedNameColor2.BackColor = localSettings.FileSettings.SelectedSettings.NameColors.Color2;
            spinnerSelectedNameAngle.Value = (decimal)localSettings.FileSettings.SelectedSettings.NameColors.Direction;

            buttonSelectedSizeColor1.BackColor = localSettings.FileSettings.SelectedSettings.SizeColors.Color1;
            buttonSelectedSizeColor2.BackColor = localSettings.FileSettings.SelectedSettings.SizeColors.Color2;
            spinnerSelectedSizeAngle.Value = (decimal)localSettings.FileSettings.SelectedSettings.SizeColors.Direction;

            buttonSelectedDateColor1.BackColor = localSettings.FileSettings.SelectedSettings.DateColors.Color1;
            buttonSelectedDateColor2.BackColor = localSettings.FileSettings.SelectedSettings.DateColors.Color2;
            spinnerSelectedDateAngle.Value = (decimal)localSettings.FileSettings.SelectedSettings.DateColors.Direction;

            #endregion

            #region ** Item MouseOver Colors **

            //buttonMouseOverNameColor1.BackColor = ApplicationSettings.MouseOverFileNameColor1;
            //buttonMouseOverNameColor2.BackColor = ApplicationSettings.MouseOverFileNameColor2;
            //spinnerMouseOverNameAngle.Value = (decimal)ApplicationSettings.MouseOverFileNameColorDirection;

            //buttonMouseOverSizeColor1.BackColor = ApplicationSettings.MouseOverFileSizeColor1;
            //buttonMouseOverSizeColor2.BackColor = ApplicationSettings.MouseOverFileSizeColor2;
            //spinnerMouseOverSizeAngle.Value = (decimal)ApplicationSettings.MouseOverFileSizeColorDirection;

            //buttonMouseOverDateColor1.BackColor = ApplicationSettings.MouseOverFileDateColor1;
            //buttonMouseOverDateColor2.BackColor = ApplicationSettings.MouseOverFileDateColor2;
            //spinnerMouseOverDateAngle.Value = (decimal)ApplicationSettings.MouseOverFileDateColorDirection;

            buttonMouseOverNameColor1.BackColor = localSettings.FileSettings.MouseOverSettings.NameColors.Color1;
            buttonMouseOverNameColor2.BackColor = localSettings.FileSettings.MouseOverSettings.NameColors.Color2;
            spinnerMouseOverNameAngle.Value = (decimal)localSettings.FileSettings.MouseOverSettings.NameColors.Direction;

            buttonMouseOverSizeColor1.BackColor = localSettings.FileSettings.MouseOverSettings.SizeColors.Color1;
            buttonMouseOverSizeColor2.BackColor = localSettings.FileSettings.MouseOverSettings.SizeColors.Color2;
            spinnerMouseOverSizeAngle.Value = (decimal)localSettings.FileSettings.MouseOverSettings.SizeColors.Direction;

            buttonMouseOverDateColor1.BackColor = localSettings.FileSettings.MouseOverSettings.DateColors.Color1;
            buttonMouseOverDateColor2.BackColor = localSettings.FileSettings.MouseOverSettings.DateColors.Color2;
            spinnerMouseOverDateAngle.Value = (decimal)localSettings.FileSettings.MouseOverSettings.DateColors.Direction;

            #endregion

            #region ** Item Selected MouseOver Colors **

            //buttonSelectedMouseOverNameColor1.BackColor = ApplicationSettings.SelectedMouseOverFileNameColor1;
            //buttonSelectedMouseOverNameColor2.BackColor = ApplicationSettings.SelectedMouseOverFileNameColor2;
            //spinnerSelectedMouseOverNameAngle.Value = (decimal)ApplicationSettings.SelectedMouseOverFileNameColorDirection;

            //buttonSelectedMouseOverSizeColor1.BackColor = ApplicationSettings.SelectedMouseOverFileSizeColor1;
            //buttonSelectedMouseOverSizeColor2.BackColor = ApplicationSettings.SelectedMouseOverFileSizeColor2;
            //spinnerSelectedMouseOverSizeAngle.Value = (decimal)ApplicationSettings.SelectedMouseOverFileSizeColorDirection;

            //buttonSelectedMouseOverDateColor1.BackColor = ApplicationSettings.SelectedMouseOverFileDateColor1;
            //buttonSelectedMouseOverDateColor2.BackColor = ApplicationSettings.SelectedMouseOverFileDateColor2;
            //spinnerSelectedMouseOverDateAngle.Value = (decimal)ApplicationSettings.SelectedMouseOverFileDateColorDirection;

            buttonSelectedMouseOverNameColor1.BackColor = localSettings.FileSettings.SelectedMouseOverSettings.NameColors.Color1;
            buttonSelectedMouseOverNameColor2.BackColor = localSettings.FileSettings.SelectedMouseOverSettings.NameColors.Color2;
            spinnerSelectedMouseOverNameAngle.Value = (decimal)localSettings.FileSettings.SelectedMouseOverSettings.NameColors.Direction;

            buttonSelectedMouseOverSizeColor1.BackColor = localSettings.FileSettings.SelectedMouseOverSettings.SizeColors.Color1;
            buttonSelectedMouseOverSizeColor2.BackColor = localSettings.FileSettings.SelectedMouseOverSettings.SizeColors.Color2;
            spinnerSelectedMouseOverSizeAngle.Value = (decimal)localSettings.FileSettings.SelectedMouseOverSettings.SizeColors.Direction;

            buttonSelectedMouseOverDateColor1.BackColor = localSettings.FileSettings.SelectedMouseOverSettings.DateColors.Color1;
            buttonSelectedMouseOverDateColor2.BackColor = localSettings.FileSettings.SelectedMouseOverSettings.DateColors.Color2;
            spinnerSelectedMouseOverDateAngle.Value = (decimal)localSettings.FileSettings.SelectedMouseOverSettings.DateColors.Direction;


            #endregion

            #region ** Background Colors **

            fslviDemo1.BackColor = localSettings.ListViewBackColor;
            fslviDemo2.BackColor = localSettings.ListViewBackColor;
            fslviDemo3.BackColor = localSettings.ListViewBackColor;

            pictureBoxBackground.BackColor = localSettings.ListViewBackColor;

            #endregion

            #region ** Fonts **

            fslviDemo1.Font = localSettings.FileSettings.PlainSettings.Font;// PlainFileFont;
            fslviDemo2.Font = localSettings.FileSettings.PlainSettings.Font;// PlainFileFont;
            fslviDemo3.Font = localSettings.FileSettings.PlainSettings.Font;// PlainFileFont;

            fslviDemo1.ForeColor = localSettings.FileSettings.PlainSettings.FontColor;// PlainFileForeColor;
            fslviDemo2.ForeColor = localSettings.FileSettings.PlainSettings.FontColor;// PlainFileForeColor;
            fslviDemo3.ForeColor = localSettings.FileSettings.PlainSettings.FontColor;// PlainFileForeColor;

            fslviDemo1.SelectedFont = localSettings.FileSettings.SelectedSettings.Font;// SelectedFileFont;
            fslviDemo2.SelectedFont = localSettings.FileSettings.SelectedSettings.Font;// SelectedFileFont;
            fslviDemo3.SelectedFont = localSettings.FileSettings.SelectedSettings.Font;// SelectedFileFont;

            fslviDemo1.SelectedForeColor = localSettings.FileSettings.SelectedSettings.FontColor;// SelectedFileForeColor;
            fslviDemo2.SelectedForeColor = localSettings.FileSettings.SelectedSettings.FontColor;// SelectedFileForeColor;
            fslviDemo3.SelectedForeColor = localSettings.FileSettings.SelectedSettings.FontColor;// SelectedFileForeColor;

            fslviDemo1.MouseOverFont = localSettings.FileSettings.MouseOverSettings.Font;// MouseOverFileFont;
            fslviDemo2.MouseOverFont = localSettings.FileSettings.MouseOverSettings.Font;// MouseOverFileFont;
            fslviDemo3.MouseOverFont = localSettings.FileSettings.MouseOverSettings.Font;// MouseOverFileFont;

            fslviDemo1.MouseOverForeColor = localSettings.FileSettings.MouseOverSettings.FontColor;// MouseOverFileForeColor;
            fslviDemo2.MouseOverForeColor = localSettings.FileSettings.MouseOverSettings.FontColor;// MouseOverFileForeColor;
            fslviDemo3.MouseOverForeColor = localSettings.FileSettings.MouseOverSettings.FontColor;// MouseOverFileForeColor;

            fslviDemo1.SelectedMouseOverFont = localSettings.FileSettings.SelectedMouseOverSettings.Font;// SelectedMouseOverFileFont;
            fslviDemo2.SelectedMouseOverFont = localSettings.FileSettings.SelectedMouseOverSettings.Font;// SelectedMouseOverFileFont;
            fslviDemo3.SelectedMouseOverFont = localSettings.FileSettings.SelectedMouseOverSettings.Font;// SelectedMouseOverFileFont;

            fslviDemo1.SelectedMouseOverForeColor = localSettings.FileSettings.SelectedMouseOverSettings.FontColor;// SelectedMouseOverFileForeColor;
            fslviDemo2.SelectedMouseOverForeColor = localSettings.FileSettings.SelectedMouseOverSettings.FontColor;// SelectedMouseOverFileForeColor;
            fslviDemo3.SelectedMouseOverForeColor = localSettings.FileSettings.SelectedMouseOverSettings.FontColor;// SelectedMouseOverFileForeColor;

            #endregion

            //OnApply();
            //DirtyFlag = false;

        }

        private void buttonColor_Click(object argSender, EventArgs argEventArgs)
        {
            Control currentButton = (Control)argSender;

            //Add any custom colors.
            _colorDialog1.CustomColors = tableLayoutPanelNameColors.Controls.OfType<DragColorButton>().Select(argCurrentControl => CorrectedColor.CorrectColor(argCurrentControl.BackColor)).ToArray();

            _colorDialog1.Color = currentButton.BackColor;

            //On a "Cancel" the dialog color will remain the same.
            _colorDialog1.ShowDialog(this);

            currentButton.BackColor = _colorDialog1.Color;

        }

        private void button_BackColorChanged(object argSender, EventArgs argEventArgs)
        {
            TableLayoutPanelCellPosition controlPosition = tableLayoutPanelNameColors.GetPositionFromControl((Control)argSender);

            DragColorButton color1Control = (DragColorButton)tableLayoutPanelNameColors.GetControlFromPosition(1, controlPosition.Row);
            string toolTipString = String.Format("[R={0}, G={1}, B={2}]", color1Control.BackColor.R, color1Control.BackColor.G, color1Control.BackColor.B);
            toolTip1.SetToolTip(color1Control, toolTipString);

            DragColorButton color2Control = (DragColorButton)tableLayoutPanelNameColors.GetControlFromPosition(2, controlPosition.Row);
            toolTipString = String.Format("A={3}, [R={0}, G={1}, B={2}]", color2Control.BackColor.R, color2Control.BackColor.G, color2Control.BackColor.B, color2Control.BackColor.A);
            toolTip1.SetToolTip(color2Control, toolTipString);

            NumericUpDown currentAngle = (NumericUpDown)tableLayoutPanelNameColors.GetControlFromPosition(3, controlPosition.Row);

            switch (controlPosition.Row)
            {
                case 1: //Plain Name
                    fslviDemo1.PlainNameColor1 = color1Control.BackColor;
                    fslviDemo1.PlainNameColor2 = color2Control.BackColor;
                    fslviDemo1.PlainNameDirection = (float)currentAngle.Value;

                    fslviDemo2.PlainNameColor1 = color1Control.BackColor;
                    fslviDemo2.PlainNameColor2 = color2Control.BackColor;
                    fslviDemo2.PlainNameDirection = (float)currentAngle.Value;

                    fslviDemo3.PlainNameColor1 = color1Control.BackColor;
                    fslviDemo3.PlainNameColor2 = color2Control.BackColor;
                    fslviDemo3.PlainNameDirection = (float)currentAngle.Value;

                    break;
                case 2: //Plain Size
                    fslviDemo1.PlainSizeColor1 = color1Control.BackColor;
                    fslviDemo1.PlainSizeColor2 = color2Control.BackColor;
                    fslviDemo1.PlainSizeDirection = (float)currentAngle.Value;

                    fslviDemo2.PlainSizeColor1 = color1Control.BackColor;
                    fslviDemo2.PlainSizeColor2 = color2Control.BackColor;
                    fslviDemo2.PlainSizeDirection = (float)currentAngle.Value;

                    fslviDemo3.PlainSizeColor1 = color1Control.BackColor;
                    fslviDemo3.PlainSizeColor2 = color2Control.BackColor;
                    fslviDemo3.PlainSizeDirection = (float)currentAngle.Value;

                    break;
                case 3://Plain Date
                    fslviDemo1.PlainDateColor1 = color1Control.BackColor;
                    fslviDemo1.PlainDateColor2 = color2Control.BackColor;
                    fslviDemo1.PlainDateDirection = (float)currentAngle.Value;


                    fslviDemo2.PlainDateColor1 = color1Control.BackColor;
                    fslviDemo2.PlainDateColor2 = color2Control.BackColor;
                    fslviDemo2.PlainDateDirection = (float)currentAngle.Value;

                    fslviDemo3.PlainDateColor1 = color1Control.BackColor;
                    fslviDemo3.PlainDateColor2 = color2Control.BackColor;
                    fslviDemo3.PlainDateDirection = (float)currentAngle.Value;

                    break;
                case 4://MouseOver Name
                    fslviDemo1.MouseOverNameColor1 = color1Control.BackColor;
                    fslviDemo1.MouseOverNameColor2 = color2Control.BackColor;
                    fslviDemo1.MouseOverNameDirection = (float)currentAngle.Value;

                    fslviDemo2.MouseOverNameColor1 = color1Control.BackColor;
                    fslviDemo2.MouseOverNameColor2 = color2Control.BackColor;
                    fslviDemo2.MouseOverNameDirection = (float)currentAngle.Value;

                    fslviDemo3.MouseOverNameColor1 = color1Control.BackColor;
                    fslviDemo3.MouseOverNameColor2 = color2Control.BackColor;
                    fslviDemo3.MouseOverNameDirection = (float)currentAngle.Value;

                    break;
                case 5://MouseOver Size
                    fslviDemo1.MouseOverSizeColor1 = color1Control.BackColor;
                    fslviDemo1.MouseOverSizeColor2 = color2Control.BackColor;
                    fslviDemo1.MouseOverSizeDirection = (float)currentAngle.Value;

                    fslviDemo2.MouseOverSizeColor1 = color1Control.BackColor;
                    fslviDemo2.MouseOverSizeColor2 = color2Control.BackColor;
                    fslviDemo2.MouseOverSizeDirection = (float)currentAngle.Value;

                    fslviDemo3.MouseOverSizeColor1 = color1Control.BackColor;
                    fslviDemo3.MouseOverSizeColor2 = color2Control.BackColor;
                    fslviDemo3.MouseOverSizeDirection = (float)currentAngle.Value;

                    break;
                case 6://MouseOver Date
                    fslviDemo1.MouseOverDateColor1 = color1Control.BackColor;
                    fslviDemo1.MouseOverDateColor2 = color2Control.BackColor;
                    fslviDemo1.MouseOverDateDirection = (float)currentAngle.Value;

                    fslviDemo2.MouseOverDateColor1 = color1Control.BackColor;
                    fslviDemo2.MouseOverDateColor2 = color2Control.BackColor;
                    fslviDemo2.MouseOverDateDirection = (float)currentAngle.Value;

                    fslviDemo3.MouseOverDateColor1 = color1Control.BackColor;
                    fslviDemo3.MouseOverDateColor2 = color2Control.BackColor;
                    fslviDemo3.MouseOverDateDirection = (float)currentAngle.Value;

                    break;
                case 7://Selected Name
                    fslviDemo1.SelectedNameColor1 = color1Control.BackColor;
                    fslviDemo1.SelectedNameColor2 = color2Control.BackColor;
                    fslviDemo1.SelectedNameDirection = (float)currentAngle.Value;

                    fslviDemo2.SelectedNameColor1 = color1Control.BackColor;
                    fslviDemo2.SelectedNameColor2 = color2Control.BackColor;
                    fslviDemo2.SelectedNameDirection = (float)currentAngle.Value;

                    fslviDemo3.SelectedNameColor1 = color1Control.BackColor;
                    fslviDemo3.SelectedNameColor2 = color2Control.BackColor;
                    fslviDemo3.SelectedNameDirection = (float)currentAngle.Value;

                    break;
                case 8://Selected Size
                    fslviDemo1.SelectedSizeColor1 = color1Control.BackColor;
                    fslviDemo1.SelectedSizeColor2 = color2Control.BackColor;
                    fslviDemo1.SelectedSizeDirection = (float)currentAngle.Value;

                    fslviDemo2.SelectedSizeColor1 = color1Control.BackColor;
                    fslviDemo2.SelectedSizeColor2 = color2Control.BackColor;
                    fslviDemo2.SelectedSizeDirection = (float)currentAngle.Value;

                    fslviDemo3.SelectedSizeColor1 = color1Control.BackColor;
                    fslviDemo3.SelectedSizeColor2 = color2Control.BackColor;
                    fslviDemo3.SelectedSizeDirection = (float)currentAngle.Value;

                    break;
                case 9://Selected Date
                    fslviDemo1.SelectedDateColor1 = color1Control.BackColor;
                    fslviDemo1.SelectedDateColor2 = color2Control.BackColor;
                    fslviDemo1.SelectedDateDirection = (float)currentAngle.Value;

                    fslviDemo2.SelectedDateColor1 = color1Control.BackColor;
                    fslviDemo2.SelectedDateColor2 = color2Control.BackColor;
                    fslviDemo2.SelectedDateDirection = (float)currentAngle.Value;

                    fslviDemo3.SelectedDateColor1 = color1Control.BackColor;
                    fslviDemo3.SelectedDateColor2 = color2Control.BackColor;
                    fslviDemo3.SelectedDateDirection = (float)currentAngle.Value;

                    break;
                case 10://MouseOver Selected Name
                    fslviDemo1.SelectedMouseOverNameColor1 = color1Control.BackColor;
                    fslviDemo1.SelectedMouseOverNameColor2 = color2Control.BackColor;
                    fslviDemo1.SelectedMouseOverNameDirection = (float)currentAngle.Value;

                    fslviDemo2.SelectedMouseOverNameColor1 = color1Control.BackColor;
                    fslviDemo2.SelectedMouseOverNameColor2 = color2Control.BackColor;
                    fslviDemo2.SelectedMouseOverNameDirection = (float)currentAngle.Value;

                    fslviDemo3.SelectedMouseOverNameColor1 = color1Control.BackColor;
                    fslviDemo3.SelectedMouseOverNameColor2 = color2Control.BackColor;
                    fslviDemo3.SelectedMouseOverNameDirection = (float)currentAngle.Value;

                    break;
                case 11://MouseOver Selected Size
                    fslviDemo1.SelectedMouseOverSizeColor1 = color1Control.BackColor;
                    fslviDemo1.SelectedMouseOverSizeColor2 = color2Control.BackColor;
                    fslviDemo1.SelectedMouseOverSizeDirection = (float)currentAngle.Value;

                    fslviDemo2.SelectedMouseOverSizeColor1 = color1Control.BackColor;
                    fslviDemo2.SelectedMouseOverSizeColor2 = color2Control.BackColor;
                    fslviDemo2.SelectedMouseOverSizeDirection = (float)currentAngle.Value;

                    fslviDemo3.SelectedMouseOverSizeColor1 = color1Control.BackColor;
                    fslviDemo3.SelectedMouseOverSizeColor2 = color2Control.BackColor;
                    fslviDemo3.SelectedMouseOverSizeDirection = (float)currentAngle.Value;

                    break;
                case 12://MouseOver Selected Date
                    fslviDemo1.SelectedMouseOverDateColor1 = color1Control.BackColor;
                    fslviDemo1.SelectedMouseOverDateColor2 = color2Control.BackColor;
                    fslviDemo1.SelectedMouseOverDateDirection = (float)currentAngle.Value;

                    fslviDemo2.SelectedMouseOverDateColor1 = color1Control.BackColor;
                    fslviDemo2.SelectedMouseOverDateColor2 = color2Control.BackColor;
                    fslviDemo2.SelectedMouseOverDateDirection = (float)currentAngle.Value;

                    fslviDemo3.SelectedMouseOverDateColor1 = color1Control.BackColor;
                    fslviDemo3.SelectedMouseOverDateColor2 = color2Control.BackColor;
                    fslviDemo3.SelectedMouseOverDateDirection = (float)currentAngle.Value;

                    break;
            }

            //PaintSampleBoxes();

            DirtyFlag = true;
        }

        private void buttonItemFontDialog_Click(object argSender, EventArgs argEventArgs)
        {

            _fontDialog1.Font = fslviDemo1.Font;
            _fontDialog1.Color = fslviDemo1.ForeColor;

            _fontDialog1.ShowDialog();

            Font currentFont = _fontDialog1.Font;
            Color currentFontColor = _fontDialog1.Color;

            fslviDemo1.Font = currentFont;
            fslviDemo1.ForeColor = currentFontColor;

            fslviDemo2.Font = currentFont;
            fslviDemo2.ForeColor = currentFontColor;

            fslviDemo3.Font = currentFont;
            fslviDemo3.ForeColor = currentFontColor;

            //PaintSampleBoxes();
            button_BackColorChanged(argSender, argEventArgs);
        }

        private void buttonMouseOverItemFontDialog_Click(object argSender, EventArgs argEventArgs)
        {

            _fontDialog1.Font = fslviDemo1.MouseOverFont;
            _fontDialog1.Color = fslviDemo1.MouseOverForeColor;

            _fontDialog1.ShowDialog();

            Font currentFont = _fontDialog1.Font;
            Color currentFontColor = _fontDialog1.Color;

            fslviDemo1.MouseOverFont = currentFont;
            fslviDemo1.MouseOverForeColor = currentFontColor;

            fslviDemo2.MouseOverFont = currentFont;
            fslviDemo2.MouseOverForeColor = currentFontColor;

            fslviDemo3.MouseOverFont = currentFont;
            fslviDemo3.MouseOverForeColor = currentFontColor;

            //PaintSampleBoxes();
            button_BackColorChanged(argSender, argEventArgs);

        }

        private void buttonSelectedItemFontDialog_Click(object argSender, EventArgs argEventArgs)
        {

            _fontDialog1.Font = fslviDemo1.SelectedFont;
            _fontDialog1.Color = fslviDemo1.SelectedForeColor;

            _fontDialog1.ShowDialog();

            Font currentFont = _fontDialog1.Font;
            Color currentFontColor = _fontDialog1.Color;

            fslviDemo1.SelectedFont = currentFont;
            fslviDemo1.SelectedForeColor = currentFontColor;

            fslviDemo2.SelectedFont = currentFont;
            fslviDemo2.SelectedForeColor = currentFontColor;

            fslviDemo3.SelectedFont = currentFont;
            fslviDemo3.SelectedForeColor = currentFontColor;

            //PaintSampleBoxes();
            button_BackColorChanged(argSender, argEventArgs);

        }

        private void buttonSelectedMouseOverItemFontDialog_Click(object argSender, EventArgs argEventArgs)
        {

            _fontDialog1.Font = fslviDemo1.SelectedMouseOverFont;
            _fontDialog1.Color = fslviDemo1.SelectedMouseOverForeColor;

            _fontDialog1.ShowDialog();

            Font currentFont = _fontDialog1.Font;
            Color currentFontColor = _fontDialog1.Color;

            fslviDemo1.SelectedMouseOverFont = currentFont;
            fslviDemo1.SelectedMouseOverForeColor = currentFontColor;

            fslviDemo2.SelectedMouseOverFont = currentFont;
            fslviDemo2.SelectedMouseOverForeColor = currentFontColor;

            fslviDemo3.SelectedMouseOverFont = currentFont;
            fslviDemo3.SelectedMouseOverForeColor = currentFontColor;

            //PaintSampleBoxes();
            button_BackColorChanged(argSender, argEventArgs);

        }

        public override void OnApply() //object sender, EventArgs argEventArgs)
        {
            if (!DirtyFlag)
            {
                return;
            }

            #region ** Normal Item Colors **

            IApplicationSettings localSettings = Locator.Resolve<IApplicationSettings>();

            localSettings.FileSettings.PlainSettings.NameColors.Color1 = fslviDemo1.PlainNameColor1;// buttonPlainNameColor1.BackColor;
            localSettings.FileSettings.PlainSettings.NameColors.Color2 = fslviDemo1.PlainNameColor2;// buttonPlainNameColor1.BackColor;
            localSettings.FileSettings.PlainSettings.NameColors.Direction = fslviDemo1.PlainNameDirection;// (float)spinnerPlainNameAngle.Value;

            localSettings.FileSettings.PlainSettings.SizeColors.Color1 = fslviDemo1.PlainSizeColor1;// buttonPlainNameColor1.BackColor;
            localSettings.FileSettings.PlainSettings.SizeColors.Color2 = fslviDemo1.PlainSizeColor2;// buttonPlainNameColor1.BackColor;
            localSettings.FileSettings.PlainSettings.SizeColors.Direction = fslviDemo1.PlainSizeDirection;// (float)spinnerPlainSizeAngle.Value;

            localSettings.FileSettings.PlainSettings.DateColors.Color1 = fslviDemo1.PlainDateColor1;// buttonPlainNameColor1.BackColor;
            localSettings.FileSettings.PlainSettings.DateColors.Color2 = fslviDemo1.PlainDateColor2;// buttonPlainNameColor1.BackColor;
            localSettings.FileSettings.PlainSettings.DateColors.Direction = fslviDemo1.PlainDateDirection;//(float)spinnerPlainDateAngle.Value;

            ////Name Nodes
            //ApplicationSettings.PlainFileNameColor1 = fslviDemo1.PlainNameColor1;// buttonPlainNameColor1.BackColor;
            //ApplicationSettings.PlainFileNameColor2 = fslviDemo1.PlainNameColor2;// buttonPlainNameColor2.BackColor;
            //ApplicationSettings.PlainFileNameColorDirection = fslviDemo1.PlainNameDirection;// (float)spinnerPlainNameAngle.Value;

            //////Size Nodes
            //ApplicationSettings.PlainFileSizeColor1 = fslviDemo1.PlainSizeColor1;// buttonPlainSizeColor1.BackColor;
            //ApplicationSettings.PlainFileSizeColor2 = fslviDemo1.PlainSizeColor2;// buttonPlainSizeColor2.BackColor;
            //ApplicationSettings.PlainFileSizeColorDirection = fslviDemo1.PlainSizeDirection;// (float)spinnerPlainSizeAngle.Value;

            //////Date Nodes
            //ApplicationSettings.PlainFileDateColor1 = fslviDemo1.PlainDateColor1;//buttonPlainDateColor1.BackColor;
            //ApplicationSettings.PlainFileDateColor2 = fslviDemo1.PlainDateColor2;//buttonPlainDateColor2.BackColor;
            //ApplicationSettings.PlainFileDateColorDirection = fslviDemo1.PlainDateDirection;//(float)spinnerPlainDateAngle.Value;

            #endregion

            #region ** Selected Item Colors **

            //Name Nodes
            localSettings.FileSettings.SelectedSettings.NameColors.Color1 = fslviDemo1.SelectedNameColor1;//buttonSelectedNameColor1.BackColor;
            localSettings.FileSettings.SelectedSettings.NameColors.Color2 = fslviDemo1.SelectedNameColor2;//buttonSelectedNameColor2.BackColor;
            localSettings.FileSettings.SelectedSettings.NameColors.Direction = fslviDemo1.SelectedNameDirection;//(float)spinnerSelectedNameAngle.Value;

            ////Size Nodes
            localSettings.FileSettings.SelectedSettings.SizeColors.Color1 = fslviDemo1.SelectedSizeColor1;//buttonSelectedSizeColor1.BackColor;
            localSettings.FileSettings.SelectedSettings.SizeColors.Color2 = fslviDemo1.SelectedSizeColor2;//buttonSelectedSizeColor2.BackColor;
            localSettings.FileSettings.SelectedSettings.SizeColors.Direction = fslviDemo1.SelectedSizeDirection;//(float)spinnerSelectedSizeAngle.Value;

            ////Date Nodes
            localSettings.FileSettings.SelectedSettings.DateColors.Color1 = fslviDemo1.SelectedDateColor1;//buttonSelectedDateColor1.BackColor;
            localSettings.FileSettings.SelectedSettings.DateColors.Color2 = fslviDemo1.SelectedDateColor2;//buttonSelectedDateColor2.BackColor;
            localSettings.FileSettings.SelectedSettings.DateColors.Direction = fslviDemo1.SelectedDateDirection;//(float)spinnerSelectedDateAngle.Value;

            #endregion

            #region ** MouseOver Item Colors **

            //Name Nodes
            localSettings.FileSettings.MouseOverSettings.NameColors.Color1 = fslviDemo1.MouseOverNameColor1;//buttonMouseOverNameColor1.BackColor;
            localSettings.FileSettings.MouseOverSettings.NameColors.Color2 = fslviDemo1.MouseOverNameColor2;//buttonMouseOverNameColor2.BackColor;
            localSettings.FileSettings.MouseOverSettings.NameColors.Direction = fslviDemo1.MouseOverNameDirection;//(float)spinnerMouseOverNameAngle.Value;

            ////Size Nodes
            localSettings.FileSettings.MouseOverSettings.SizeColors.Color1 = fslviDemo1.MouseOverSizeColor1;//buttonMouseOverSizeColor1.BackColor;
            localSettings.FileSettings.MouseOverSettings.SizeColors.Color2 = fslviDemo1.MouseOverSizeColor2;//buttonMouseOverSizeColor2.BackColor;
            localSettings.FileSettings.MouseOverSettings.SizeColors.Direction = fslviDemo1.MouseOverSizeDirection;//(float)spinnerMouseOverSizeAngle.Value;

            ////Date Nodes
            localSettings.FileSettings.MouseOverSettings.DateColors.Color1 = fslviDemo1.MouseOverDateColor1;//buttonMouseOverDateColor1.BackColor;
            localSettings.FileSettings.MouseOverSettings.DateColors.Color2 = fslviDemo1.MouseOverDateColor2;//buttonMouseOverDateColor2.BackColor;
            localSettings.FileSettings.MouseOverSettings.DateColors.Direction = fslviDemo1.MouseOverDateDirection;//(float)spinnerMouseOverDateAngle.Value;

            #endregion

            #region ** MouseOver Selected Item Colors **

            //Name Nodes
            localSettings.FileSettings.SelectedMouseOverSettings.NameColors.Color1 = fslviDemo1.SelectedMouseOverNameColor1;//buttonSelectedMouseOverNameColor1.BackColor;
            localSettings.FileSettings.SelectedMouseOverSettings.NameColors.Color2 = fslviDemo1.SelectedMouseOverNameColor2;//buttonSelectedMouseOverNameColor2.BackColor;
            localSettings.FileSettings.SelectedMouseOverSettings.NameColors.Direction = fslviDemo1.SelectedMouseOverNameDirection;//(float)spinnerSelectedMouseOverNameAngle.Value;

            //Size Nodes
            localSettings.FileSettings.SelectedMouseOverSettings.SizeColors.Color1 = fslviDemo1.SelectedMouseOverSizeColor1;//buttonSelectedMouseOverSizeColor1.BackColor;
            localSettings.FileSettings.SelectedMouseOverSettings.SizeColors.Color2 = fslviDemo1.SelectedMouseOverSizeColor2;//buttonSelectedMouseOverSizeColor2.BackColor;
            localSettings.FileSettings.SelectedMouseOverSettings.SizeColors.Direction = fslviDemo1.SelectedMouseOverSizeDirection;//(float)spinnerSelectedMouseOverSizeAngle.Value;

            //Date Nodes
            localSettings.FileSettings.SelectedMouseOverSettings.DateColors.Color1 = fslviDemo1.SelectedMouseOverDateColor1;//buttonSelectedMouseOverDateColor1.BackColor;
            localSettings.FileSettings.SelectedMouseOverSettings.DateColors.Color2 = fslviDemo1.SelectedMouseOverDateColor2;//buttonSelectedMouseOverDateColor2.BackColor;
            localSettings.FileSettings.SelectedMouseOverSettings.DateColors.Direction = fslviDemo1.SelectedMouseOverDateDirection;//(float)spinnerSelectedMouseOverDateAngle.Value;

            #endregion

            #region ** Font info **
            localSettings.FileSettings.PlainSettings.Font = fslviDemo1.Font;//labelItemFont.Font;
            localSettings.FileSettings.PlainSettings.FontColor = fslviDemo1.ForeColor;//labelItemFont.ForeColor;
            localSettings.FileSettings.SelectedSettings.Font = fslviDemo1.SelectedFont;
            localSettings.FileSettings.SelectedSettings.FontColor = fslviDemo1.SelectedForeColor;
            localSettings.FileSettings.MouseOverSettings.Font = fslviDemo1.MouseOverFont;
            localSettings.FileSettings.MouseOverSettings.FontColor = fslviDemo1.MouseOverForeColor;
            localSettings.FileSettings.SelectedMouseOverSettings.Font = fslviDemo1.SelectedMouseOverFont;
            localSettings.FileSettings.SelectedMouseOverSettings.FontColor = fslviDemo1.SelectedMouseOverForeColor;

            #endregion

            localSettings.Save();
            DirtyFlag = false;

        }

    }
}
